package com.yaojiaxun.logisticsPlatformSystem.mapper;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.yaojiaxun.logisticsPlatformSystem.entity.CarInformation;
import org.apache.ibatis.annotations.*;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @Auther: yjx_j
 * @Date: 2019/1/15 12:59
 * @Description:
 */
@Mapper
public interface CarInformationMapper extends BaseMapper<CarInformation> {
    @Insert("insert into `car_information`(`car_id`,`car_number`,`car_type`,`car_length`,`car_load`,`car_belong`,`car_place_province`,`car_place_city`,`car_place_country`,`create_time`,`update_time`) " +
            "values(#{carInformation.carId}, #{carInformation.carNumber}, #{carInformation.carType}, #{carInformation.carLength}, #{carInformation.carLoad}, " +
            "#{carInformation.carBelong},#{carInformation.carPlaceProvince},#{carInformation.carPlaceCity},#{carInformation.carPlaceCountry},#{carInformation.createTime},#{carInformation.updateTime})")
    public Integer addCarInformation(@Param("carInformation") CarInformation carInformation);

    @Delete("delete from car_information where car_id=#{carId}")
    public void deleteCarById(@Param("carId") Integer carId);

    @Update("update `car_information` set `car_number`=#{carNumber}, `car_type`=#{carType}, `car_length`=#{carLength}," +
            "`car_load`=#{carLoad}, `car_belong`=#{carBelong}, `car_place_province`=#{carPlaceProvince},`car_place_city`=#{carPlaceCity},`car_place_country`=#{carPlaceCountry} where `car_id`=#{carId}")
    public Integer updateCarByCarId(@RequestParam("carInformation") CarInformation carInformation);

    @Select("select * from `car_information` where `car_id`=#{carId}")
    public CarInformation findCarByCarId(@Param("carId") Integer carId);

    @Select("select * from `car_information` where `car_number`=#{carNumber}")
    public CarInformation findCarByCarNumber(@Param("carNumber") String carNumber);
}
